<%--
  Created by IntelliJ IDEA.
  User: KangFaWei
  Date: 2019/7/12
  Time: 10:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:include page="/web/inc/header"/>
<section>
    <div class="wrap">
        <div id="seach">
            <div id="logo" class="qanda"><a href="http://fenlicx.qinglab.cn" title="垃圾分类问答">垃圾分类问答</a></div>
            <form id="my-form" action="<%=path%>/web/question/searchList" method="post">
                <div class="qanda">
                    <input type="text" required id="keyword" value="${param.keyword}" name="keyword" class="seach_txt" aria-label="输入搜索问题"
                           placeholder="输入搜索问题">
                    <input type="button" class="seach_bun" id="search-question" value="搜问题">
                    <a class="seach_bun" href="<%=path%>/web/question/add">提问题</a>
                </div>
            </form>
        </div>
        <article class="article">
            <div class="aaa">
                <h1 style="font-size: 30px">为您搜索到以下关于"<span style="color: #1094fa;">${param.keyword}</span>"的内容：</h1>
            </div>
            <div id="list-question">

            </div>
        </article>
    </div>
</section>
<script>
    $(function () {
        questionList("${param.keyword}",1);

        $("#list-question").on("click",".show-page",function () {
            var pageNum=$(this).html();

            questionList("${param.keyword}",pageNum);
        })
    })
    function questionList(keyword,pageNum){
        $.ajax({
            url:"<%=path%>/web/question/searchData",
            data:{pageNum:pageNum,keyword:keyword},
            success:function(mes){
                $("#list-question").empty();
                $("#list-question").append(mes);
            }
        })
    }

    $("#search-question").click(function () {
        var keyword = $("#keyword").val();

        if (keyword.trim().length!=0)
        {
            $("#my-form").submit();
        }
    })
</script>
<jsp:include page="/web/inc/footer"/>
